import { User, UserProfile } from '@/types/data'
import { ProfileAction } from '@/types/store'

type State = {
  user: User,
  userProfile: UserProfile
}
// 初始值
const initState:State = {
  user: {},
  userProfile: {}
} as State

console.log(initState)
export default function profile (state = initState, action: ProfileAction) {
  console.log(action)
  if (action.type === 'profile/getUser') {
    return { ...state, user: action.payload }
  } else if (action.type === 'profile/getUserProfile') {
    return { ...state, userProfile: action.payload }
  }
  return state
}
